<template>
	<div v-if="isLogin === true">
		<view class="wrap-tab">
			<view class="tab-item" :class="{ active: tab_index === 0 }" @click.stop="tab_index = 0">
				我的信息
				<view class="line" v-if="tab_index === 0"></view>
			</view>

			<view class="tab-item" :class="{ active: tab_index === 1 }" @click.stop="tab_index = 1">
				我的赛事
				<view class="line" v-if="tab_index === 1"></view>
			</view>
		</view>

		<userInfo v-if="tab_index === 0" />
		<mineEvent v-if="tab_index === 1" />
	</div>
</template>

<script>
	import mineEvent from "./mineEvent.vue";
	import userInfo from "./userInfo.vue";
	export default {
		components: {
			userInfo,
			mineEvent,
		},
		data() {
			return {
				isLogin: null, //是否登录
				tab_index: 0, //当前tab索引
			};
		},
		onShow() {
			this.isLogin = this.$filters.isLogin();
		},
		onPullDownRefresh() {
			if (this.tab_index === 0) {
				uni.stopPullDownRefresh();
				return;
			}
			uni.$emit("onRefresh");
		},
		onReachBottom() {
			if (this.tab_index === 0) {
				return;
			}
			uni.$emit("onLoadMore");
		},
		methods: {},
	};
</script>

<style lang="scss" scoped>
	page {
		background-color: #f6f6f6;
	}
	.wrap-tab {
		position: sticky;
		left: 0;
		top: 0;
		width: 100%;
		height: 120rpx;
		z-index: 10;
		background-color: #f7f7f7;
		display: flex;
		flex-wrap: wrap;

		.active {
			font-weight: bold;
			color: #ea5520 !important;
		}
		.tab-item {
			flex: 1;
			height: 120rpx;
			line-height: 120rpx;
			color: #333;
			font-size: 30rpx;
			text-align: center;
			overflow: hidden;
			position: relative;
			z-index: 11;

			.line {
				position: absolute;
				left: 50%;
				bottom: 24rpx;
				width: 34rpx;
				height: 6rpx;
				transform: translateX(-50%);
				border-radius: 3rpx;
				overflow: hidden;
				z-index: 12;
				background-color: #ea5520;
			}
		}
	}
</style>
